package com.czk.classanlysis;

import com.czk.utils.FileUtil;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.Opcodes;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/8/26 18:06
 */
public class MethodFindRefCore {
    public static void main(String[] args) {
        String path = "F:\\IdeaProjects\\asm\\target\\classes\\com\\czk\\sample\\Calculate.class";
        byte[] bytes = FileUtil.readBytes(path);
        ClassReader cr = new ClassReader(bytes);
        //（2）分析ClassVisitor
        int api = Opcodes.ASM9;
        ClassVisitor cv = new MethodFindRefVisitor(api, null, "com/czk/sample/Calculate","test", "(III)V");

        //（3）结合ClassReader和ClassVisitor
        int parsingOptions = ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES;
        cr.accept(cv, parsingOptions);
    }
}
